package com.hong.chapter4;

import com.hong.chapter3.MyClassLoader;

import java.lang.reflect.Method;

/**
 * @Auther: Administrator
 * @Date: 2018/7/18 00:10
 * @Description:
 */
public class ClassLoaderTest {
    public static void main(String[] args) throws Exception {
        MyClassLoader classLoader = new MyClassLoader();
        classLoader.setDir("C:\\Users\\Administrator\\IdeaProjects\\classLoader\\src\\main\\java\\com\\hong\\chapter4\\test");
        Class<?> aClass = classLoader.loadClass("com.hong.chapter4.ClassLoaderTest");
        System.out.println(aClass);
//        System.out.println(aClass.getClassLoader());
        Object obj = aClass.newInstance();
        Method method = aClass.getMethod("hello",new Class<?>[]{});
        Object result = method.invoke(obj,new Object[]{});
        System.out.println(result);
    }
}
